package com.komorebishao.code;

public class Code977 {



    public static int[] sortArray(int[] nums) {
        int n = nums.length;
        int[] result = new int[n];
        for (int i = 0, j = n - 1, position = n - 1; i <= j;) {
            if (nums[i] * nums[i] > nums[j] * nums[j]) {
                result[position] = nums[i] * nums[i];
                i++;
            } else {
                result[position] = nums[j] * nums[j];
                j--;
            }
            position++;
        }
        return result;
    }
}
